package scau.cn.fat;

import java.io.Serializable;

/**
 * 鏂囦欢鍒嗛厤琛� 255浠ｈ〃缁撴潫 0浠ｈ〃绌洪棽 128浠ｈ〃鎹熷潖
 */
public class FAT implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Fat的总容量，单位为块
	 */
	private final int space = 128;
	private int[] fat = new int[128];
	//-------------------鏋勯�犲櫒--------------------------------------------
	public FAT() {
		for(int i = 0; i < 128; i++) {
			if(i < 3) {
				fat[i] = 255;
			} else {
				fat[i] = 0;
			}
		}
	}
	public int getStatus(int i) {
		return fat[i];
	}

	public void setStatus(int i, int status) {
		if (i <= 127 && i >= 2) {
			fat[i] = status;
		}
	}

	/**
	 * @return -1 鎵句笉鍒�
	 */
	public byte findFree() {
		for (int i = 2; i < fat.length; i++) {
			if (fat[i] == 0) {
				return (byte) i;
			}
		}
		return -1;
	}
	
	//-------------------------------访问器，修改器---------------------------------
	public int getSpace() {
		return space;
	}
}
